package UILayer;

import java.util.Scanner;
import CtrlLayer.*;
import ModelLayer.*;
/**
 * Write a description of class MainMenu here.
 * 
 * @author (Group A) 
 * @version (2014.11.03)
 */
public class Menu
{
    private ManagerUI managerUI;
    private EmployeeUI employeeUI;

    public Menu()
    {
        managerUI = new ManagerUI();
        employeeUI = new EmployeeUI();
    }

    public void mainMenuStart()
    {
        boolean exit=false;
        while (!exit) //! means while exit not is true (that is: false)
        {
            int choise = writeMainMenu();

            switch (choise) 
            {
                case 1: managerUI.managerMenuStart();
                break;
                case 2: employeeUI.employeeMenuStart();
                break;
                case 3: writeEnd();
                exit = true;
                break;
            }
        }//end while
    }//end start

    private int writeMainMenu()
    {  
        int choise = 0;
        try
        {
            // creates a keyboard object to read input
            Scanner keyboard = new Scanner(System.in);
            System.out.println("\f *** MainMenu ***");
            System.out.println(" (1) Manager");
            System.out.println(" (2) Employee");
            System.out.println(" (3) Exit");

            choise = keyboard.nextInt();
        }
        catch(Exception e)
        {
            System.out.println("ERROR!");
            writeMainMenu();
        }
        return choise;
    }

    private void pause()
    {
        Scanner keyboard = new Scanner(System.in);
        String vent = keyboard.nextLine();
    }

    private void writeEnd()
    {
        System.out.println("The system is safe to leave!");
    }    
}